package com.unohacha.qqj.fzdr.main;

import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.view.View;
import android.view.ViewTreeObserver;
import android.view.Window;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.unohacha.qqj.fzdr.R;
import com.unohacha.qqj.fzdr.view.ObservableScrollView;
import com.unohacha.qqj.mylibrary.base.BaseActivity;
import com.youth.banner.Banner;

import butterknife.BindView;
import butterknife.ButterKnife;

public class FindDetailActivity extends BaseActivity implements ObservableScrollView.ScrollViewListener {


    @BindView(R.id.scrollview)
    ObservableScrollView scrollView;
    @BindView(R.id.common_back)
    ImageView commonBack;
    @BindView(R.id.common_title)
    TextView commonTitle;
    @BindView(R.id.common_right_image)
    ImageView commonRightImage;
    @BindView(R.id.common_right_text)
    TextView commonRightText;
    @BindView(R.id.home1_title)
    LinearLayout home1Title;
    @BindView(R.id.banner)
    Banner banner;
    @BindView(R.id.store_logo_iv)
    ImageView storeLogoIv;
    @BindView(R.id.store_name_tv)
    TextView storeNameTv;
    @BindView(R.id.store_report_content)
    TextView storeReportContent;
    @BindView(R.id.report_time_tv)
    TextView reportTimeTv;
    @BindView(R.id.content_detail)
    TextView contentDetail;
    @BindView(R.id.tv_type)
    TextView tvType;

    private int imageHeight;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_find_detail;
    }

    @Override
    protected void initView() {
        super.initView();
        initListeners();
        
    }

    private void initListeners() {
        // 获取顶部图片高度后，设置滚动监听  
        ViewTreeObserver vto = banner.getViewTreeObserver();
        vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
            @Override
            public void onGlobalLayout() {
                banner.getViewTreeObserver().removeGlobalOnLayoutListener(
                        this);
                imageHeight = banner.getHeight();

                scrollView.setScrollViewListener(FindDetailActivity.this);
            }
        });
    }


    @Override
    public void onScrollChanged(ObservableScrollView scrollView, int x, int y, int oldx, int oldy) {
        if (y <= 0) {
            home1Title.setBackgroundColor(Color.argb((int) 0, 255, 255, 255));//AGB由相关工具获得，或者美工提供  
        } else if (y > 0 && y <= imageHeight) {
            float scale = (float) y / imageHeight;
            float alpha = (255 * scale);
            // 只是layout背景透明(仿知乎滑动效果)  
            home1Title.setBackgroundColor(Color.argb((int) alpha, 255, 255, 255));
        } else {
            home1Title.setBackgroundColor(Color.argb((int) 255, 255, 255, 255));
        }
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
    }
    
}
